package mc

import (
	"gitee.com/dreamwood/ez-go/db/mgo"
)

const (
	InLogEventNew           = "wms.InLogNew"
	InLogEventBeforeCreate  = "wms.InLogBeforeCreate"
	InLogEventBeforeUpdate  = "wms.InLogBeforeUpdate"
	InLogEventBeforeSave    = "wms.InLogBeforeCreate wms.InLogBeforeUpdate"
	InLogEventAfterCreate   = "wms.InLogAfterCreate"
	InLogEventAfterUpdate   = "wms.InLogAfterUpdate"
	InLogEventAfterSave     = "wms.InLogAfterCreate wms.InLogAfterUpdate"
	InLogEventDelete        = "wms.InLogDelete"
	InLogAccessControlEvent = "wms.InLogAccessControl"
)

func GetInLogConfig() *mgo.DocConfig {
	return InLog_Config
}

var InLog_Config *mgo.DocConfig

func init() {
	InLog_Config = NewInLogConfig()
}
func NewInLogConfig() *mgo.DocConfig {
	return &mgo.DocConfig{
		ContainerKey: "wms.InLog",
		Fields: []string{
			"sn", "item", "type", "department", "isCanceled", "numIn", "numInReal", "numOut", "numLeft", "batchCode", "batchPrice", "cost", "costReal", "heapCode", "pos", "supplier", "brand", "link", "linkTo", "note", "createBy", "createName",
		},
		RelationFields: []string{
			"item", "type", "department",
		},
		RelationConfigs: map[string]*mgo.DocRelation{
			"item": {
				Config:     GetItemSkuConfig,
				DocName:    "ItemSku",
				JoinType:   "O",
				KeyInside:  "itemId",
				KeyOutSide: "id",
			},
			"type": {
				Config:     GetIOTypeConfig,
				DocName:    "IOType",
				JoinType:   "O",
				KeyInside:  "typeId",
				KeyOutSide: "id",
			},
			"department": {
				Config:     GetDepartmentConfig,
				DocName:    "Department",
				JoinType:   "O",
				KeyInside:  "departmentId",
				KeyOutSide: "id",
			},
		},
		FieldFilter: map[string]*mgo.DocFieldFilter{
			"default": {
				Select: []string{},
				Omit:   []string{},
			},
		},
	}
}
